package com.k.ums.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.beans.Transient;
import java.util.Collection;

/**
 * @Description:
 * @Author: kt
 * @CreateTime: 2022/1/27
 */
@Data
public class LoginUser implements UserDetails {

    private String token;

    private SysUser sysUser;

    private long expireTime;

    public LoginUser(){}

    public LoginUser(SysUser sysUser) {
        this.sysUser = sysUser;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    @JsonIgnore
    @Transient
    public String getPassword() {
        return sysUser.getPassword();
    }

    @Override
    @JsonIgnore
    @Transient
    public String getUsername() {
        return sysUser.getUserName();
    }

    @Override
    @JsonIgnore
    @Transient
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    @JsonIgnore
    @Transient
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    @JsonIgnore
    @Transient
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    @JsonIgnore
    @Transient
    public boolean isEnabled() {
        return true;
    }
}
